package com.efast.cafe.portal.service.statemach.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.efast.cafe.framework.constant.CommonConstant;
import com.efast.cafe.framework.redis.ObjectRedisTemplate;
import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.cafe.portal.bean.statemach.PortalStateMachRel;
import com.efast.cafe.portal.bean.statemach.PortalStateMachRelBean;
import com.efast.cafe.portal.bean.statemach.PortalStateMachRelQueryBean;
import com.efast.cafe.portal.dao.statemach.PortalStateMachRelDao;
import com.efast.cafe.portal.service.statemach.IPortalStateMachRelService;

@Service
@Transactional
public class PortalStateMachRelServiceImpl implements IPortalStateMachRelService {

	@Autowired
	private PortalStateMachRelDao portalStateMachRelDao;

	@Autowired
	private ObjectRedisTemplate objectRedisTemplate;

	@Override
	public void insertRel(PortalStateMachRel rel) {
		portalStateMachRelDao.insertRel(rel);
	}

	@Override
	public void updateRel(PortalStateMachRel rel) {
		portalStateMachRelDao.updateRel(rel);
		// 删除缓存
		objectRedisTemplate.delete(CommonConstant.REDIS_STATEMACH_CONFID_ + rel.getConfId());
	}

	@Override
	public void deleteRel(PortalStateMachRel rel) {
		portalStateMachRelDao.deleteRel(rel);
		// 删除缓存
		objectRedisTemplate.delete(CommonConstant.REDIS_STATEMACH_CONFID_ + rel.getConfId());
	}

	@Override
	public PortalStateMachRelQueryBean queryPageRelMachState(PortalStateMachRelQueryBean queryBean) {
		queryBean.setCompanyCode(SpringWebUtils.getRequestCompany());
		queryBean.setResultList(portalStateMachRelDao.queryRelPageList(queryBean));
		queryBean.setTotalRows(portalStateMachRelDao.queryRelPageCount(queryBean));
		return queryBean;
	}

	@Override
	public List<PortalStateMachRelBean> queryRelListByPara(Long handleId, Long stateId) {
		return portalStateMachRelDao.queryRelListByPara(handleId, stateId);
	}

	@Override
	public void deleteRelByConfId(Long confId) {
		portalStateMachRelDao.deleteRelByConfId(confId);
	}

}
